<template>
    <v-details :inputConfig="inputConfig" :detailData="inputData" :rules="rules" ref="input" @pop="setdata"></v-details>
</template>

<script>
    import details from 'commons/Detail'
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        props: {
            inputData: {
                type: Object,
            }
        },
        mixins: [baseMixin],
        name: "",
        data() {
            return {
                rules: {
                    cust_code: [
                        {required: true, trigger: 'blur'},
                    ],
                    charge_code: [
                        {required: true, trigger: 'blur'},
                    ],
                    tax_flag: [
                        {required: true, trigger: 'blur'},
                    ],
                    bill_to: [
                        {required: true, trigger: 'blur'},
                    ],
                    charge_uom: [
                        {required: true, trigger: 'blur'},
                    ],
                    internal_flag: [
                        {required: true, trigger: 'blur'},
                    ],
                    facility_id: [
                        {required: true, trigger: 'blur'},
                    ],
                    charge_qty: [
                        {required: true, trigger: 'blur'},
                    ],
                    charge_date: [
                        {required: true, trigger: 'blur'},
                    ],
                    charge_rate: [
                        {required: true, trigger: 'blur'},
                    ],
                    invoice_status: [
                        {required: true, trigger: 'blur'},
                    ],
                },
            }
        },
        computed: {
            inputConfig() {
                return [
                    [
                        {
                            type: "table",
                            label: this.$t('bill.customer'),
                            props: "cust_code",
                            tableConfig: [
                                {
                                    label: this.$t('bill.customer'),
                                    prop: "cust_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.customerDesc'),
                                    prop: "cust_desc",
                                    input: "input",
                                }
                            ],
                            url: `/queryRpt/1/?/${this.$store.state.wms}`
                        },
                        {
                            type: "input",
                            label: this.$t('bill.orderNo'),
                            props: "order_no",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.orderLine'),
                            props: "order_line",
                        },
                        {
                            type: "input",
                            label: "UC1",
                            props: "uc1",
                        },
                        {
                            type: "table",
                            label: this.$t('bill.chargeCode'),
                            props: "charge_code",
                            tableConfig: [
                                {
                                    label: this.$t('bill.chargeCode'),
                                    prop: "charge_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.chargeCodeDesc'),
                                    prop: "charge_desc",
                                    input: "input",
                                }
                            ],
                            url: `/queryChargeCodeList/`
                        },
                        {
                            type: "select",
                            label: this.$t('bill.tax'),
                            props: "tax_flag",
                            options: this.getOptions("codelkup/ISCLOSE")
                        },
                        {
                            type: "input",
                            label: this.$t('bill.skuQty'),
                            props: "qty_bal",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.loadQty'),
                            props: "load_bal",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.gross'),
                            props: "grs_bal",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.suttle'),
                            props: "net_bal",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.volume'),
                            props: "cube_bal",
                        },
                    ],
                    [
                        {
                            type: "table",
                            label: this.$t('bill.billTo'),
                            props: "bill_to",
                            tableConfig: [
                                {
                                    label: this.$t('bill.billTo'),
                                    prop: "bill_to_cust",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.desc'),
                                    prop: "name",
                                    input: "input",
                                }
                            ],
                            url: `/queryBillToList/${this.$store.state.wms}/`
                        },
                        {
                            type: "input",
                            label: this.$t('bill.orderType'),
                            props: "order_type",
                        },
                        {
                            type: "table",
                            label: this.$t('bill.goods'),
                            props: "item",
                            tableConfig: [
                                {
                                    label: this.$t('bill.goods'),
                                    prop: "item",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.goodsGroupDesc'),
                                    prop: "item_desc",
                                    input: "input",
                                }
                            ],
                            url: `/queryItemList/${this.$store.state.wms}/`
                        },
                        {
                            type: "input",
                            label: "UC2",
                            props: "uc2",
                        },
                        {
                            type: "table",
                            label: this.$t('bill.chargeUom'),
                            props: "charge_uom",
                            tableConfig: [
                                {
                                    label: this.$t('bill.uomCode'),
                                    prop: "uom_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomDesc'),
                                    prop: "uom_desc",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomType'),
                                    prop: "uom_type_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/UOMTYPE")
                                },
                                {
                                    label: this.$t('bill.fieldPercentage'),
                                    prop: "per_of_field",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.measureSystem'),
                                    prop: "measure_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/MEASURESYS")
                                },
                                {
                                    label: this.$t('bill.measureUom'),
                                    prop: "measure_uom",
                                    input: "input",
                                },
                            ],
                            url: `/queryUomList/`
                        },
                        {
                            type: "select",
                            label: this.$t('bill.internal'),
                            props: "internal_flag",
                            options: this.getOptions('codelkup/ISCLOSE')
                        },
                        {
                            type: "table",
                            label: this.$t('bill.skuUom'),
                            props: "qty_uom",
                            tableConfig: [
                                {
                                    label: this.$t('bill.uomCode'),
                                    prop: "uom_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomDesc'),
                                    prop: "uom_desc",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomType'),
                                    prop: "uom_type_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/UOMTYPE")
                                },
                                {
                                    label: this.$t('bill.fieldPercentage'),
                                    prop: "per_of_field",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.measureSystem'),
                                    prop: "measure_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/MEASURESYS")
                                },
                                {
                                    label: this.$t('bill.measureUom'),
                                    prop: "measure_uom",
                                    input: "input",
                                },
                            ],
                            url: `/queryUomList/`
                        },
                        {
                            type: "table",
                            label: this.$t('bill.loadUom'),
                            props: "load_uom",
                            tableConfig: [
                                {
                                    label: this.$t('bill.uomCode'),
                                    prop: "uom_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomDesc'),
                                    prop: "uom_desc",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomType'),
                                    prop: "uom_type_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/UOMTYPE")
                                },
                                {
                                    label: this.$t('bill.fieldPercentage'),
                                    prop: "per_of_field",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.measureSystem'),
                                    prop: "measure_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/MEASURESYS")
                                },
                                {
                                    label: this.$t('bill.measureUom'),
                                    prop: "measure_uom",
                                    input: "input",
                                },
                            ],
                            url: `/queryUomList/`
                        },
                        {
                            type: "table",
                            label: this.$t('bill.weightUom'),
                            props: "wgt_uom",
                            tableConfig: [
                                {
                                    label: this.$t('bill.uomCode'),
                                    prop: "uom_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomDesc'),
                                    prop: "uom_desc",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomType'),
                                    prop: "uom_type_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/UOMTYPE")
                                },
                                {
                                    label: this.$t('bill.fieldPercentage'),
                                    prop: "per_of_field",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.measureSystem'),
                                    prop: "measure_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/MEASURESYS")
                                },
                                {
                                    label: this.$t('bill.measureUom'),
                                    prop: "measure_uom",
                                    input: "input",
                                },
                            ],
                            url: `/queryUomList/`
                        },
                        {
                            type: "table",
                            label: this.$t('bill.volumeUom'),
                            props: "cube_uom",
                            tableConfig: [
                                {
                                    label: this.$t('bill.uomCode'),
                                    prop: "uom_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomDesc'),
                                    prop: "uom_desc",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomType'),
                                    prop: "uom_type_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/UOMTYPE")
                                },
                                {
                                    label: this.$t('bill.fieldPercentage'),
                                    prop: "per_of_field",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.measureSystem'),
                                    prop: "measure_code",
                                    input: "select",
                                    options: this.getOptions("codelkup/MEASURESYS")
                                },
                                {
                                    label: this.$t('bill.measureUom'),
                                    prop: "measure_uom",
                                    input: "input",
                                },
                            ],
                            url: `/queryUomList/`
                        },
                    ],
                    [
                        {
                            type: "select",
                            label: this.$t('bill.wareHouse'),
                            props: "facility_id",
                            options: this.getOptions("getSelectCode/FACILITY_ID/NAME/BIC_FACILITY/1=1")
                        },
                        {
                            type: "table",
                            label: this.$t('bill.activity'),
                            props: "activity_id",
                            tableConfig: [
                                {
                                    label: this.$t('bill.activity'),
                                    prop: "activity_id",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomDesc'),
                                    prop: "activity_desc",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.activityType'),
                                    prop: "activity_type",
                                    input: "select",
                                    options: this.getOptions("getSelectCode/ACTIVITY_TYPE/ACTIVITY_TYPE_DESC/BIC_ACTIVITY_TYPE/1=1")
                                },
                                {
                                    label: this.$t('bill.wareHouse'),
                                    prop: "facility_id",
                                    input: "select",
                                    options: this.getOptions("getSelectCode/FACILITY_ID/NAME/BIC_FACILITY/1=1")
                                }
                            ],
                            url: `/queryActivityList/${this.$store.state.wms}/`
                        },
                        {
                            type: "input",
                            label: this.$t('bill.package'),
                            props: "pkg",
                        },
                        {
                            type: "input",
                            label: "UC3",
                            props: "uc3",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.chargeQty'),
                            props: "charge_qty",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.cost'),
                            props: "rate_cost",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.comment'),
                            props: "charge_comment",
                        },
                    ],
                    [
                        {
                            type: "date",
                            label: this.$t('bill.chargeDate'),
                            props: "charge_date",
                        },
                        {
                            type: "select",
                            label: this.$t('bill.invoiceType'),
                            props: "invoice_type",
                            options: this.getOptions("getSelectCode/INVOICE_TYPE/INV_TYPE_DESC/BIC_CODE_INVTYPE/language='zh'")
                        },
                        {
                            type: "input",
                            label: this.$t('bill.lotCode'),
                            props: "lot_code",
                        },
                        {
                            type: "input",
                            label: this.$t('bill.minValue'),
                            props: "min_flag",
                            disabled: true
                        },
                        {
                            type: "input",
                            label: this.$t('bill.rate'),
                            props: "charge_rate",
                        },
                        {
                            type: "table",
                            label: this.$t('bill.rateGroup'),
                            props: "rate_group",
                            tableConfig: [
                                {
                                    label: this.$t('bill.rateGroup'),
                                    prop: "rate_group",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.uomDesc'),
                                    prop: "rate_group_desc",
                                    input: "input",
                                }
                            ],
                            url: `/queryRateGroupList/${this.$store.state.wms}/`
                        },
                    ],
                    [
                        {
                            type: "select",
                            label: this.$t('bill.invoiceStatus'),
                            props: "invoice_status",
                            options: this.getOptions("getSelectCode/INVOICE_STATUS/INV_STATUS_DESC/BIC_CODE_INVSTATUS/language='zh' and ui_flag='Y'")
                        },
                        {
                            type: "input",
                            label: this.$t('bill.batchNo'),
                            props: "batch_no",
                            disabled: true
                        },
                        {
                            type: "input",
                            label: this.$t('bill.invoice'),
                            props: "invoice_no",
                            disabled: true
                        },
                        {
                            type: "input",
                            label: this.$t('bill.currency'),
                            props: "charge_curr_code",
                            disabled: true
                        },
                        {
                            type: "input",
                            label: this.$t('bill.chargeAmount'),
                            props: "charge_amt",
                            disabled: true
                        },
                        {
                            type: "table",
                            label: this.$t('bill.eventGroup'),
                            props: "event_group",
                            tableConfig: [
                                {
                                    label: this.$t('bill.eventGroup'),
                                    prop: "event_group",
                                    input: "input",
                                },
                                {
                                    label: this.$t('bill.eventGroupDesc'),
                                    prop: "event_desc",
                                    input: "input",
                                }
                            ],
                            url: `/queryEventList/${this.$store.state.wms}/`
                        },
                        {
                            type: "input",
                            label: this.$t('bill.chargeNot'),
                            props: "charge_no",
                            disabled: true
                        },
                        {
                            type: "select",
                            label: this.$t('bill.separateAmount'),
                            props: "separate_by_break",
                            options: this.getOptions("codelkup/INTLEAVTSK"),
                            disabled: true
                        }
                    ]
                ]
            },
        },
        methods: {
            setdata(data, id, close, listId) {
                if (listId == "0" && id == "0") {
                    this.inputData.cust_code = data.cust_code
                }
                if (listId == "0" && id == "4") {
                    this.inputData.charge_code = data.charge_code;
                }
                if (listId == "1" && id == "0") {
                    this.inputData.bill_to = data.bill_to_cust;
                }
                if (listId == "1" && id == "2") {
                    this.inputData.item = data.item;
                }
                if (listId == "1" && id == "4") {
                    this.inputData.charge_uom = data.uom_code;
                }
                if (listId == "1" && id == "6") {
                    this.inputData.qty_uom = data.uom_code;
                }
                if (listId == "1" && id == "7") {
                    this.inputData.load_uom = data.uom_code;
                }
                if (listId == "1" && id == "8") {
                    this.inputData.wgt_uom = data.uom_code;
                }
                if (listId == "1" && id == "9") {
                    this.inputData.cube_uom = data.uom_code;
                }
                if (listId == "2" && id == "1") {
                    this.inputData.activity_id = data.activity_id;
                }
                if (listId == "3" && id == "5") {
                    this.inputData.rate_group = data.rate_group;
                }
                if (listId == "4" && id == "5") {
                    this.inputData.event_group = data.event_group;
                }
                close(false);
            }
        },
        mounted() {
        },
        watch: {},
        components: {
            'v-details': details
        }
    }
</script>

<style scoped>

</style>
